package com.geekteam.manga.Model;

import android.content.ContentValues;
import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.BaseColumns;

import com.geekteam.manga.provider.MangaContract.MangaChap;

public class MangaChapModel extends BaseModel{
	
	private String mangaId;
	private String chapId;
	private String chapName;
	private int chapNumber;
	
	public MangaChapModel(int _id, String mangaId, String chapId, String chapName, int chapNumber){
		super(_id);
		this.mangaId = mangaId;
		this.chapId = chapId;
		this.chapName = chapName;
		this.chapNumber = chapNumber;
	}

	public MangaChapModel(Cursor cursor) {
		super(cursor);
		this._id = cursor.getInt(cursor.getColumnIndex(BaseColumns._ID));
		mangaId = cursor.getString(cursor.getColumnIndex(MangaChap.MANGA_ID));
		chapId = cursor.getString(cursor.getColumnIndex(MangaChap.MANGACHAP_CHAPID));
		chapName = cursor.getString(cursor.getColumnIndex(MangaChap.MANGACHAP_NAME));
		chapNumber = cursor.getInt(cursor.getColumnIndex(MangaChap.MANGACHAP_NUMBER));
		
	}
	
	public ContentValues contentValues(long id){
		ContentValues values = new ContentValues();
		
		values.put(MangaChap.MANGA_ID, mangaId);
		values.put(MangaChap.MANGACHAP_CHAPID, chapId);
		values.put(MangaChap.MANGACHAP_NAME, chapName);
		values.put(MangaChap.MANGACHAP_NUMBER, chapNumber);
		return values;
	}
	
	 static public String[] contentColumns (){
			return new String[] {MangaChap.MANGA_ID, MangaChap.MANGACHAP_CHAPID, 
					MangaChap.MANGACHAP_NAME,MangaChap.MANGACHAP_NUMBER, MangaChap._ID};
		 }

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(_id);
		dest.writeString(mangaId);
		dest.writeString(chapId);
		dest.writeString(chapName);
		dest.writeInt(chapNumber);
		
	}
	
	public void readFromParcel(Parcel from){
		_id = from.readInt();
		mangaId  =from.readString();
		chapId = from.readString();
		chapName = from.readString();
		chapNumber = from.readInt();
	}
	
	public MangaChapModel (Parcel parcel){
		super(parcel);
		readFromParcel(parcel);
		
	}
	
	@SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR = new Parcelable.Creator<MangaChapModel>() {

		@Override
		public MangaChapModel createFromParcel(Parcel source) {
			return new MangaChapModel(source);
		}

		@Override
		public MangaChapModel[] newArray(int size) {
			return new MangaChapModel[size];
		}
	};
	
	public void setMangaId(String mangaId){
		this.mangaId = mangaId;
	}
	
	public String getMangaId(){
		return mangaId;
	}
	
	public void setChapId(String chapId){
		this.chapId = chapId;
	}
	
	public String getChapId(){
		return chapId;
	}
	
	public void setChapName(String chapName){
		this.chapName = chapName;
	}
	
	public String getChapName(){
		return chapName;
	}
	
	public void setChapNumber(int chapNumber){
		this.chapNumber = chapNumber;
	}
	
	public int getChapNumber(){
		return chapNumber;
	}
	

}
